package com.soushin.chinachess.base;

import com.soushin.chinachess.R;

import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class BaseActivity extends Activity{

	/**
	 * 设置返回按钮
	 * @param isBack
	 */
	protected void setBack(boolean isBack) {
		ImageView imgBack=(ImageView)findViewById(R.id.img_back);
		if(isBack) {
			imgBack.setVisibility(View.VISIBLE);
			imgBack.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					finish();
				}
			});
		}else {
			imgBack.setVisibility(View.GONE);
		}
	}
	
	/**
	 * 设置标题
	 * @param title
	 */
	protected void setTitle(String title) {
		TextView tvTitle=(TextView)findViewById(R.id.tv_title);
		tvTitle.setText(title);
	}
	
	/**
	 * 上下文
	 * @return
	 */
	protected Activity getActivity() {
		return this;
	}
	
	/**
	 * 提示信息
	 * @param msg
	 */
	protected void showsToasty(String msg) {
		Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT).show();
	}
	/**
	 * 跳转
	 * @param clazz
	 */
	protected void goTo(Class clazz) {
		startActivity(new Intent(getActivity(),clazz));
	}
}
